/* 
接口请求函数模块
返回一个promise对象
*/
import userAxios from './request'

// 登陆
export const reqLogin = (username, pwd) => userAxios({
  url: '/admin/login',
  method: 'post',
  data: {username, pwd}
})

// 获取登陆用户
export const reqInfo = () => userAxios({
  url: `/admin/info`,
  method: 'get',
})

// 退出登陆
export const reqLogOut = () => userAxios({
  url: '/admin/logout',
})

// 添加用户
export const reqAddUser = (formData) => userAxios({
  url: '/admin/user',
  method: 'post',
  data: formData
})

// 更新用户
export const reqUpdateUser = (formData) => userAxios({
  url: '/admin/user',
  method: 'put',
  data: formData
})

// 删除用户
export const reqDeleteUser = (id) => userAxios({
  url: '/admin/user/' + id,
  method: 'delete',
})

// 获取用户分页列表
export const reqGetUsers = (page, limit) => userAxios({
  url: `/admin/user/${page}/${limit}`,
  method: 'get',
})

// 获取用户信息
export const reqGetUser = (id) => userAxios({
  url: `/admin/user`,
  method: 'get',
  params: {id}
})